# -*- coding: UTF-8 -*-
"""
    @Author:YTQ
    @Time: 2022/7/20 19:00
    Description: 保存和更新准确率
    
"""


# 保存和更新准确率
class AverageMeter(object):

    def __init__(self):
        self.avg = 0
        self.sum = 0
        self.cnt = 0
        self.reset()

    def reset(self):
        self.avg = 0
        self.sum = 0
        self.cnt = 0

    def update(self, val, n=1):
        self.sum += val * n
        self.cnt += n
        self.avg = self.sum / self.cnt
